#!/usr/bin/env python
# -*- coding:utf-8 -*-
__author__ = 'shawn'

from xml.etree.ElementTree import Element,parse,fromstring

#parse 加载文件
tree = parse('movies.xml')

#getroot是return the root element of the tree
print(tree.getroot())

root = tree.getroot()

#child.tag获取节点名,child.attrib获取节点属性值,child.text获取节点值
for child in root:
    print("*"*5+child.tag+"*"*5)
    for k,v in child.attrib.items():
        print(k+":",v)
    for line in child.getchildren():
        print(line.tag+":",line.text)

print('#'*20)
root = tree.find('movie')
for line in root:
    print(line.tag,line.text)

